<!-- src/views/Login.vue -->
<template>
  <div class="login-container">
    <h2>登录</h2>
    <form @submit.prevent="handleLogin">
      <div class="form-group">
        <label>用户名</label>
        <input v-model="form.username" type="text" required>
      </div>
      <div class="form-group">
        <label>密码</label>
        <input v-model="form.password" type="password" required>
      </div>
      <button type="submit">登录</button>
      <p v-if="error" class="error-message">{{ error }}</p>
    </form>
    <router-link to="/register">前往注册</router-link>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import axios from 'axios'

const router = useRouter()
const form = ref({ username: '', password: '' })
const error = ref('')

const handleLogin = async () => {
 // try {
  //  const response = await axios.post('http://localhost:5000/api/login', form.value)
  //  if (response.data.status === 'success') {
      router.push('/EssayGuide')
  //  }
 // } catch (err) {
  //  error.value = err.response?.data?.message || '登录失败'
 ///  }
}
</script>